<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      let str = prompt('请输入检测的数据')

      function getStr(str) {
        const obj = {}
        const str1 = str.split('')
        console.log(str1);
        str1.forEach((item) => {
          if (obj[item]) {
            obj[item]++
          } else {
            obj[item] = 1
          }
        })
        console.log(obj);
        let arr = []
        for (let k in obj) {
          arr.push(obj[k])
        }
        const min = Math.min(...arr)
        console.log(min)

        let arr1 = []
        for (let k in obj) {
          if (obj[k] === min) {
            arr1.push(k)
          }
        }
        console.log(arr1);

        arr1.map((item) => {
          str = str.replaceAll(`${item}`,'')
        })
       
        return str
      }
      console.log(getStr(str))
    </script>
  </body>
</html>
